Skip to content

test(vexpdif): rewrite pto_vexpdif_fusion as vreg-level pto-test-opt case - #18

Merged
liuzidi merged 1 commit into
main-llvm19-buildfrom
fix/pto-vexpdif-fusion-vreg-level-lit
Aug 31, 2026
Merged

test(vexpdif): rewrite pto_vexpdif_fusion as vreg-level pto-test-opt case#18
liuzidi merged 1 commit into
main-llvm19-buildfrom
fix/pto-vexpdif-fusion-vreg-level-lit

Conversation

@liuzidi

@liuzidi liuzidi commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

Rewrite test/lit/tile_fusion/pto_vexpdif_fusion.pto from an end-to-end ptoas pipeline test into a hand-written vreg-level case exercised via pto-test-opt -pto-vexpdif-fusion, matching the pattern of the mask/f16/multiuse siblings.

Problem

On a clean main-llvm19-build checkout (0003225f4), pto_vexpdif_fusion.pto failed:

CHECK: pto.vexpdif {{.*}} "ODD"   <- expected
actual: two separate local-boundary scf.for loops (template_tsub / template_texp),
        vsub result written via vsts then reloaded via vlds for vexp

The end-to-end RUN drove the test through TileLib template expansion, where tsub/texp fall back to ordinary PTODSL templates in separate local-boundary loops (boundary_reason = "non_vmi_local_boundary_fallback"). The intervening vsts/vlds broke the vsub -> vexp SSA chain that PTOVexpdifFusion matches (exp.getInput().getDefiningOp<VsubOp>()), so the pass never fired.

Fix

Rewrite as hand-written vreg IR, decoupled from the ptoas pipeline, TileLib templates, and local-boundary fallback:

func.func @vexpdif_fusion(%a : !pto.vreg<64xf32>, %b : !pto.vreg<64xf32>) -> !pto.vreg<64xf32> {
  %res = pto.fusion_region {
    %m = pto.pset_b32 "PAT_ALL" : !pto.mask<b32>
    %sub = pto.vsub %a, %b, %m : ...
    %exp = pto.vexp %sub, %m : ...
    pto.yield(%exp) : ...
  } : !pto.vreg<64xf32>
  ...
}
// CHECK: pto.vexpdif {{.*}} "ODD"
// CHECK-NOT: pto.vsub
// CHECK-NOT: pto.vexp {{.*}} :
  • vsub single-use feeding vexp, sharing one mask SSA inside one fusion_region — exactly the shape canFuse requires.
  • Drops the second LLVM RUN line; it depended on the full ptoas pipeline, and vexpdif LLVM lowering is already covered by test/lit/vmi_new/vmi_to_vpto_vexpdif_f16.pto and vmi_layout_assignment_vexpdif.pto.

Verification

All four vexpdif-fusion lit tests pass on main-llvm19-build:

pto_vexpdif_fusion        PASS
pto_vexpdif_fusion_mask   PASS
pto_vexpdif_fusion_f16    PASS
pto_vexpdif_fusion_multiuse PASS

Scope

Single file, test-only change.

…case

The end-to-end ptoas RUN drove the test through TileLib template
expansion, where tsub/texp fall back to ordinary PTODSL templates in
separate local-boundary loops. The intervening vsts/vlds broke the
vsub->vexp SSA chain that PTOVexpdifFusion matches, so the pass never
fired and the lit failed on a clean main-llvm19-build checkout.

Rewrite the case as hand-written vreg IR exercised via pto-test-opt, the
same pattern used by the mask/f16/multiuse siblings. A single-use f32
vsub feeding vexp inside one fusion_region with one shared mask SSA now
fuses into pto.vexpdif "ODD" as intended. This decouples the positive
f32 fusion case from the ptoas pipeline, TileLib templates, and
local-boundary fallback behavior.

Drop the second RUN that lowered to LLVM IR; it depended on the full
ptoas pipeline and its coverage is already provided by
test/lit/vmi_new/vmi_to_vpto_vexpdif_f16.pto and
vmi_layout_assignment_vexpdif.pto.
@liuzidi
liuzidi merged commit 67e2ad4 into main-llvm19-build Aug 31, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant